/**
 * 
 */
package com.babel.util.tools;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

/**
 * 
 * @Description:TODO
 * 
 * @author:silence
 * 
 * @time:2017年6月9日 下午5:02:10
 * 
 */
public class CopyListTools<S, T> {

	private Class<T> targetType;

	public CopyListTools(Class<T> targetType) {
		this.targetType = targetType;
	}

	private List<T> copy(List<S> src) {

		List<T> target = new ArrayList<T>();

		for (S s : src) {

			T t = BeanUtils.instantiateClass(targetType);
			BeanUtils.copyProperties(s, t);
			target.add(t);

		}

		return target;
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static List copyList(Class vClass, List list) {

		CopyListTools cvt = new CopyListTools(vClass);

		return cvt.copy(list);
	}
	
	

}
